import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import java.util.ArrayList; 
import oracle.jdbc.pool.OracleDataSource;

public class getAgents extends HttpServlet
{
	public static dbapi conn;
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
	{
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println("<a href=\"./index.html\">home</a><br><br>");
		conn = new dbapi();
		conn.connect();
		if(!conn.connected)
		{
			out.println("SQL ERROR CANNOT CONNECT TO DATABASE!<br>");
			out.println(conn.msg + "<br>");
			return;
		}
		ArrayList<String> agentList = conn.getAgents();
		if(agentList == null){
			out.println("Error: null resultset from database<br>"+conn.msg);
			return;	
		}else{
			for(int i=0;i<agentList.size();i++)
			{
				out.println(agentList.get(i) + "<br>");
			}	
		}
	}
}
